package com.bert.controller;

import com.bert.entity.TestEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/path/{number}")
    public String path(@PathVariable String number) {
//        try {
//            Thread.sleep(10000);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        return "provider-one: " + number;
    }

    @GetMapping("/param")
    public String param(@RequestParam("a") Integer a, @RequestParam("b") Integer b) {
        if (b == 0) {
            return "provider-one: " + 0;
        }
        else {
            return "provider-one: " + (a / b);
        }
    }

    @PostMapping("/post")
    public TestEntity post(@RequestBody TestEntity entity) {
        return new TestEntity(entity.getId() + 1, "provider-one: " + entity.getName());
    }

}
